package com.nintendo.controller;


import com.nintendo.pojo.Users;
import com.nintendo.pojo.bo.ModifyUserBO;
import com.nintendo.pojo.bo.RegistLoginBO;
import com.nintendo.pojo.vo.UsersVO;
import com.nintendo.result.GraceJSONResult;
import com.nintendo.service.UsersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/auth")
@Slf4j
public class AuthController {

    @Autowired
    private UsersService usersService;
    @PostMapping("/send-code")
    public GraceJSONResult sendCode(@RequestParam("mobile")String mobile, HttpServletRequest request){
        log.info("sendCode=================>,{}",mobile);
       usersService.sendCode(mobile,request);
        return GraceJSONResult.ok();
    }
    @PostMapping("/login")
    public GraceJSONResult login(@RequestBody RegistLoginBO registLoginBO){
        UsersVO usersVO = usersService.login(registLoginBO);
        return GraceJSONResult.ok(usersVO);
    }
    @PostMapping("/modify-user-info")
    public GraceJSONResult modifyUserInfo(@RequestBody ModifyUserBO modifyUserInfo,HttpServletRequest request){
        UsersVO usersVO = usersService.modifyUserInfo(modifyUserInfo,request);
        return GraceJSONResult.ok(usersVO);
    }
    @PostMapping("/normal")
    public GraceJSONResult register(){

        return GraceJSONResult.ok("normal");
    }
}
